import request from '@/config/axios'

export interface FittingVO {
  id: number
  fittingName: string
  fittingType: number
  fittingStatus: number
  expired: number
  expiredTime: Date
  fittingModel: string
  description: string
  albumPics: string
  changeTime: Date
  scrapTime: Date
  deviceId: number
}

// 查询设备管理列表
export const getFittingPage = (params: PageParam) => {
  return request.get({ url: '/bms/fitting/page', params })
}

// 查询所有设备列表
export const getAllFitting = () => {
  return request.get({ url: '/bms/fitting/all' })
}

// 查询设备详情
export const getFitting = (id: number) => {
  return request.get({ url: '/bms/fitting/get?id=' + id })
}

// 新增设备
export const createFitting = (data: FittingVO) => {
  return request.post({ url: '/bms/fitting/create', data })
}

// 修改设备
export const updateFitting = (data: FittingVO) => {
  return request.put({ url: '/bms/fitting/update', data })
}

// 删除设备
export const deleteFitting = (id: number) => {
  return request.delete({ url: '/bms/fitting/delete?id=' + id })
}

// 配件状态修改
export const updateFittingStatus = (id: number, fittingStatus: number) => {
  const data = {
    id,
    fittingStatus
  }
  return request.put({ url: '/bms/fitting/update-status', data: data })
}

// 获取设备精简信息列表
export const getSimpleFittingList = (): Promise<FittingVO[]> => {
  return request.get({ url: '/bms/fitting/simple-list' })
}

// 获取设备精简信息列表
export const syncAsset = () => {
  return request.get({ url: '/bms/fitting/sync-asset' })
}
